//"use strict";
//advertiserApp.controller("advertiserCtrl",function($scope,$http){	 
//	 $http.post("/web-adv/finishPlacementAd").success(function(data){
//		 $scope.tableData = data.beans;	
//		 //console.log($scope.tableData)		 
//	 });
//	 //时间格式转换
//	 $scope.translate = function(t){
//		 t = t.replace(/-/g,'/');
//		 t = t.split(".")[0];		 
//		 var date = new Date(t);		 
//		 return date.getTime();
//	 };	 
//	 // 删除已投放广告（伪删除）	  
//	 $scope.deleteAd = function(id){
//		 var msg = "您确定要删除此条广告吗？";
//			if (confirm(msg)){			
//				$.ajax({
//					url : '/web-adv/deletePlacementAd',
//			        data:{adId:id},
//					type : 'post',
//					success : function(data) {			
//						if(data.status =='1'){
//							$http.post("/web-adv/finishPlacementAd").success(function(data){
//								$scope.tableData = data.beans;									
//							});
//						}else{
//							console.log("删除失败！");
//						}
//					},
//			        error: function(){}        
//				});
//			};		 
//	 };
//	 $scope.details = function(value){
//		 if(value=="video") return true;
//		 return false;		 
//	 }
//	
//});
/**
 * 查看已投放图片广告
 */
var translate = function(t){
			 t = t.split(" ")[0];	
			 t=t.replace("-","年");
			 t=t.replace("-","月");
			 return t;
		};

var LocString=String(window.document.location.href);
 function GetQueryString(str){
	 var rs=new RegExp("(^|)"+str+"=([^&]*)(&|$)","gi").exec(LocString),tmp;
	 if(tmp=rs)return tmp[2];
	 return "没有这个参数";
 }//获取url中的数据
var pictureSaveUrl = "http://114.116.41.171:8089/pictures/";//服务器保存图片的路径
//var pictureSaveUrl = "http://192.168.3.67:8089/pictures/";//服务器保存图片的路径
function queryPictureAd(){
	var adId = GetQueryString("adId");
	
	$.ajax({
		url : '/web-adv/viewPlacementAd',
        data:{adId:adId},
		type : 'post',
		success : function(data) {
//			var resultVo = data.resultVo;
//			var picServerPrex = resultVo.picServerPrex;
//			var ads = data.bean;
//			$("#adName").html(ads.adName);	
//			$(".adCoverImg").attr("src",picServerPrex+ads.adHomepage);
			var beans = data.beans;
			var type = beans[0].deliveryCarrier;
			$("#time").text(translate(beans[0].starTime)+"日"+"--"+translate(beans[0].endTime)+"日");
			$("#adName").text(beans[0].adName);
			$("#adImage").attr("src",pictureSaveUrl+beans[0].adHomepage);
			$("#adReleaseAmount").text(beans[0].releaseAmount+"(元)");
			$("#adDeliveryPrice").text(beans[0].deliveryPrice+"(次/元)");
			$("#adImageHome").prop("value",pictureSaveUrl+beans[0].adHomepage);
			$("#adLunBoImg").prop("value",beans[0].lastUrl);
			$("#typeImage").text(beans[0].deliveryCarrier);
			$("#idLogo").attr("src",pictureSaveUrl+beans[0].adHomepage);
			if(type=='pad'){
				$("#typeImg").prop("src","/web-adv/advWeb/static/images/padIcon.png");
		       }
		       if(type=='pc'){
		    	   $("#typeImg").prop("src","/web-adv/advWeb/static/images/pcIcon.png");
		       }
		       if(type=='mobile'){
		    	   $("#typeImg").prop("src","/web-adv/advWeb/static/images/mobileIcon.png");
		       }
		       if(type=='tv'){
		    	   $("#typeImg").prop("src","/web-adv/advWeb/static/images/tvIcon.png");
		       }
			for(var j = 0;j<beans.length;j++){
				if(beans[j].channelName!=null){
					var li = "<li><img class='' src='"+pictureSaveUrl+beans[j].logoUrl+"' alt=''>" +
					"<button class='btn btn-primary left'>"+beans[j].channelName+"</button>" +
					"<div class='right'><p><span>" +
					"投放金额：</span><span>"+beans[j].channelAmount+"(元)</span></p>\<p>" +
					"<span>投放单价：</span><span>"+beans[j].channelPrice+"(次/元)</span></p></div>" +
					"<div class='clear'></div></li>";
					$("#placement").append(li);
				}
			}
			//广告属性标签
			var classfyIds = beans[0].adClassify.split("|");
			for(var i =0;i<classfyIds.length;i++){
				if(classfyIds[i].length != 0){
				//	console.log(classfyIds[i]);
					var li = "<li><img src=\"/web-adv/advWeb/static/images/genres_pic"+classfyIds[i]+".png\" alt=\"\" /></li>";
					$("#adClassify").append(li);
				}
			}
		},
        error: function(){}        
	});
}
/**
 * 浏览已投放图片广告
 */
function viewPicture(){
	var picturePage = $("#adImageHome").val();
	var pictureUrl = $("#adLunBoImg").val();
	$("#pictureAdImg").prop("src",picturePage);
	$("#pictureUl").children().remove();
	 var beans = pictureUrl.split("|");
	 for(var i=0;i<beans.length;i++){
		 if(beans[i]==""||beans[i]==null){
			 beans.splice([i],1);
		 }
		 var li = '<li><img src="'+pictureSaveUrl+beans[i]+'" alt="" /></li>';
		 $("#pictureUl").append(li);
	 }
}




